﻿using System.Collections.Generic;

namespace Comdiv.QWeb.Utils.LogicalExpressionLanguage {
	public abstract class LogicalExpressionNode {
		protected LogicalExpressionNode() {
			Children = new List<LogicalExpressionNode>();
		}

		public bool Negative { get; set; }
		public IList<LogicalExpressionNode> Children { get; private set; }

		public bool Eval(ILogicTermSource source) {
			var result = internalEval(source);
			if (Negative) result = !result;
			return result;
		}

		protected abstract bool internalEval(ILogicTermSource source);
	}
}